package com.tzstcl.sys.user.service.impl;

import com.tzstcl.base.service.impl.BaseServiceImpl;
import com.tzstcl.sys.user.mapper.SysPostMapper;
import com.tzstcl.sys.user.model.SysPost;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author haocj
 * 用户service
 */
@Service
public class SysPostService extends BaseServiceImpl<SysPostMapper, SysPost> {

    @Resource
    private SysPostMapper sysPostMapper;

    @Transactional(readOnly = false, rollbackFor = Exception.class)
    public void save(SysPost sysPost) {
        if (null==sysPost.getId()) {
            sysPost.preInit();
            sysPostMapper.save(sysPost);
        } else {
            sysPost.preInit();
            sysPostMapper.update(sysPost);
        }

    }


    public List<SysPost> findListAll(SysPost sysPost) {
        List<SysPost> list = sysPostMapper.findListAll(sysPost);
        if (list.size() > 0) {
            return list;
        }
        return new ArrayList<>();
    }


    @Transactional(readOnly = false, rollbackFor = Exception.class)
    public Integer delete(String[] ids) {
        return sysPostMapper.delete(ids);
    }

}
